import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import  axios from 'axios'
import echarts from 'echarts'
import storage from './utils/storage'

Vue.prototype.axios  =  axios
Vue.prototype.$echarts = echarts
Vue.use(ElementUI);
Vue.config.productionTip = false
axios.defaults.baseURL  =  '/api'
router.beforeEach((to, from, next) => {
    if (to.meta.isLogin) {
        //判断是否登录
        if (storage.getStorage('user')) {
            next()
        } else {
            router.push('/login')
        }
    } else {
        next()
    }
})
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')